/**
 * This is my code.
 *
 * $Id$
 */
package fi.jab.esb.config.xml.impl;

import fi.jab.esb.config.xml.SimpleScheduleType;
import fi.jab.esb.config.xml.XmlPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>Simple Schedule Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link fi.jab.esb.config.xml.impl.SimpleScheduleTypeImpl#getExecCount <em>Exec Count</em>}</li>
 *   <li>{@link fi.jab.esb.config.xml.impl.SimpleScheduleTypeImpl#getFrequency <em>Frequency</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class SimpleScheduleTypeImpl extends ScheduleImpl implements SimpleScheduleType
{
  /**
   * The default value of the '{@link #getExecCount() <em>Exec Count</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExecCount()
   * @generated
   * @ordered
   */
  protected static final int EXEC_COUNT_EDEFAULT = -1;

  /**
   * The cached value of the '{@link #getExecCount() <em>Exec Count</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getExecCount()
   * @generated
   * @ordered
   */
  protected int execCount = EXEC_COUNT_EDEFAULT;

  /**
   * This is true if the Exec Count attribute has been set.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   * @ordered
   */
  protected boolean execCountESet;

  /**
   * The default value of the '{@link #getFrequency() <em>Frequency</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFrequency()
   * @generated
   * @ordered
   */
  protected static final long FREQUENCY_EDEFAULT = 10L;

  /**
   * The cached value of the '{@link #getFrequency() <em>Frequency</em>}' attribute.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @see #getFrequency()
   * @generated
   * @ordered
   */
  protected long frequency = FREQUENCY_EDEFAULT;

  /**
   * This is true if the Frequency attribute has been set.
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   * @ordered
   */
  protected boolean frequencyESet;

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  protected SimpleScheduleTypeImpl()
  {
    super();
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  protected EClass eStaticClass()
  {
    return XmlPackage.Literals.SIMPLE_SCHEDULE_TYPE;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public int getExecCount()
  {
    return execCount;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setExecCount(int newExecCount)
  {
    int oldExecCount = execCount;
    execCount = newExecCount;
    boolean oldExecCountESet = execCountESet;
    execCountESet = true;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SIMPLE_SCHEDULE_TYPE__EXEC_COUNT, oldExecCount, execCount, !oldExecCountESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void unsetExecCount()
  {
    int oldExecCount = execCount;
    boolean oldExecCountESet = execCountESet;
    execCount = EXEC_COUNT_EDEFAULT;
    execCountESet = false;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.UNSET, XmlPackage.SIMPLE_SCHEDULE_TYPE__EXEC_COUNT, oldExecCount, EXEC_COUNT_EDEFAULT, oldExecCountESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isSetExecCount()
  {
    return execCountESet;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public long getFrequency()
  {
    return frequency;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void setFrequency(long newFrequency)
  {
    long oldFrequency = frequency;
    frequency = newFrequency;
    boolean oldFrequencyESet = frequencyESet;
    frequencyESet = true;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.SET, XmlPackage.SIMPLE_SCHEDULE_TYPE__FREQUENCY, oldFrequency, frequency, !oldFrequencyESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public void unsetFrequency()
  {
    long oldFrequency = frequency;
    boolean oldFrequencyESet = frequencyESet;
    frequency = FREQUENCY_EDEFAULT;
    frequencyESet = false;
    if (eNotificationRequired())
      eNotify(new ENotificationImpl(this, Notification.UNSET, XmlPackage.SIMPLE_SCHEDULE_TYPE__FREQUENCY, oldFrequency, FREQUENCY_EDEFAULT, oldFrequencyESet));
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  public boolean isSetFrequency()
  {
    return frequencyESet;
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public Object eGet(int featureID, boolean resolve, boolean coreType)
  {
    switch (featureID)
    {
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__EXEC_COUNT:
        return new Integer(getExecCount());
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__FREQUENCY:
        return new Long(getFrequency());
    }
    return super.eGet(featureID, resolve, coreType);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eSet(int featureID, Object newValue)
  {
    switch (featureID)
    {
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__EXEC_COUNT:
        setExecCount(((Integer)newValue).intValue());
        return;
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__FREQUENCY:
        setFrequency(((Long)newValue).longValue());
        return;
    }
    super.eSet(featureID, newValue);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public void eUnset(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__EXEC_COUNT:
        unsetExecCount();
        return;
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__FREQUENCY:
        unsetFrequency();
        return;
    }
    super.eUnset(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public boolean eIsSet(int featureID)
  {
    switch (featureID)
    {
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__EXEC_COUNT:
        return isSetExecCount();
      case XmlPackage.SIMPLE_SCHEDULE_TYPE__FREQUENCY:
        return isSetFrequency();
    }
    return super.eIsSet(featureID);
  }

  /**
   * <!-- begin-user-doc -->
   * <!-- end-user-doc -->
   * @generated
   */
  @Override
  public String toString()
  {
    if (eIsProxy()) return super.toString();

    StringBuffer result = new StringBuffer(super.toString());
    result.append(" (execCount: ");
    if (execCountESet) result.append(execCount); else result.append("<unset>");
    result.append(", frequency: ");
    if (frequencyESet) result.append(frequency); else result.append("<unset>");
    result.append(')');
    return result.toString();
  }

} //SimpleScheduleTypeImpl
